#ifndef SEARCHWIG_H
#define SEARCHWIG_H

#include <QWidget>
#include <QTcpSocket>
#include <QUdpSocket>
#include <QFile>
#include <QFileDialog>
#include <QMessageBox>
#include <QHostAddress>
#include <QNetworkInterface>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>


namespace Ui {
class searchwig;
}

class searchwig : public QWidget
{
    Q_OBJECT

public:
    explicit searchwig(QWidget *parent = 0);
    ~searchwig();

private slots:
    void on_search_button_clicked();

    void on_online_button_clicked();

    void on_ota_button_clicked();

    void processUdpResponse();      //处理udp响应

    void sendDiscoveryBroadcast();  //广播

    void connectToTcpServer(const QString &ip, quint16 port); //连接tcp

    void onTcpConnected();                // TCP连接成功

    void onTcpDisconnected();             // TCP断开连接

    void onTcpReadyRead();                // 读取TCP数据

    void onTcpError(QAbstractSocket::SocketError error); // TCP错误处理

    void sendFile(const QString &filePath); // 发送文件



private:
    Ui::searchwig *ui;

    QTcpSocket *tcpSocket;

    QUdpSocket *udpSocket;

    bool deviceOnline;



signals:
    void IpSignal(const QString ip);

};

#endif // SEARCHWIG_H
